package com.usian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usian.mapper.TbItemCatMapper;
import com.usian.pojo.TbItemCat;
import com.usian.service.TbItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author chen
 * @date 2021/1/9 - 19:14 - 星期六
 * @project usian_parent
 * @package com.usian.service.impl
 * @by GGbomd猪猪侠
 */
@Service
@Transactional
public class TbItemCatServiceImpl implements TbItemCatService {

    @Autowired
    private TbItemCatMapper tbItemCatMapper;

    /**
     * 查询分类表 根据父节点查询子节点
     * @param id
     * @return
     */
    @Override
    public List<TbItemCat> selectItemCategoryByParentId(Long id) {
        QueryWrapper<TbItemCat> itemCatQueryWrapper = new QueryWrapper<>();
        //eq 比较查询status状态为1的
        itemCatQueryWrapper.eq("status",1);
        //eq 比较查询比较parent_id父节点对应传来的id
        itemCatQueryWrapper.eq("parent_id",id);
        List<TbItemCat> tbItemCatList = tbItemCatMapper.selectList(itemCatQueryWrapper);
        return tbItemCatList;
    }
}
